/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication2;

import br.usp.icmc.lasdpc.gem.xml.schema.Experimenttype;
import br.usp.icmc.lasdpc.gem.xml.schema.Filetype;
import br.usp.icmc.lasdpc.gem.xml.schema.Seqparametertype;
import br.usp.icmc.lasdpc.gem.xml.schema.Valparametertype;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.SchemaFactoryLoader;
import org.xml.sax.SAXException;

/**
 *
 * @author ljr
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException, JAXBException, SAXException {
		Schema schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI).newSchema(new File("/tmp/e.xml"));

		JAXBContext context = JAXBContext.newInstance(Experimenttype.class);
		Unmarshaller um = context.createUnmarshaller();
		um.setSchema(schema);
		Object ob = um.unmarshal(new FileReader("/tmp/e.xml"));
		Experimenttype experiment = (Experimenttype) ob;

		System.out.print("Owner:" + experiment.getOwner());
		System.out.print("Project:" + experiment.getProjectname());
		System.out.print("Executable:" + experiment.getExecutable());
		System.out.print("Prefix:" + experiment.getPrefix());
		System.out.print("Postfix:" + experiment.getPostfix());

		System.out.print("Targets:");
		for (Filetype file : experiment.getTargets().getFile()) {
			System.out.print("File type:" + file.getType());
			System.out.print("File resource:" + file.getResource());
			System.out.print("File name:" + file.getFile());
		}

		System.out.print("Sequential Parameters:");
		for (Seqparametertype param : experiment.getSequentialparameters().getSeqparameter()) {
			System.out.print("Order:" + param.getOrder());
			System.out.print("Parameter beging:" + param.getBegin());
			System.out.print("Parameter end:" + param.getEnd());
			System.out.print("Parameter increment:" + param.getIncrement());
		}

		System.out.print("Value Parameters:");
		for (Valparametertype param : experiment.getValueparameters().getValparameter()) {
			System.out.print("Order:" + param.getOrder());
			for (String value : param.getValue()) {
				System.out.print("Value:" + value);
			}
		}
	}

}

